home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
util
/
urlprotocol.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
135 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
__all__ = 'isRegistered register unregister'.split()
import platform
from traceback import print_exc
from warnings import warn
platform = platform.system().lower()
platform = {
'microsoft': 'windows',
'4nt': 'windows',
'darwin': 'darwin',
'linux': 'linux' }.get(platform, 'windows')
def attrget(obj, attr):
try:
return obj[attr]
except TypeError:
return obj.name
def platform_call(name, *a, **k):
funcname = name + '_' + platform
try:
func = globals()[funcname]
except KeyError:
warn('platform %s not implemented (%s)' % (platform, funcname))
return func(*a, **k)
def isRegistered(urlprotocol, system = True):
return platform_call('isDefault', urlprotocol, system = system)
def get(protocol_name, system = True):
return platform_call('get', protocol_name, system = system)
def register(urlprotocol, system = True):
return platform_call('register', urlprotocol, system = system)
def unregister(protocol_or_name, system = True):
name = None if isinstance(protocol_or_name, basestring) else getattr(protocol_or_name, 'name', protocol_or_name['name'])
return platform_call('unregister', name, system = system)
def _init_darwin():
pass
def _init_windows():
global reg
import _winreg as reg
def get_windows(protocol_name, system = True):
fuzzydecode = fuzzydecode
import util
key = reg.OpenKey(basekey(system), '%s\\shell\\open\\command' % protocol_name)
val = reg.EnumValue(key, 0)[1]
if isinstance(val, str):
val = fuzzydecode(reg.EnumValue(key, 0)[1], 'utf-16-be')
return val
def urlkey(protocolname, system = False, write = False):
try:
if system:
return None(reg.OpenKey, reg.HKEY_CLASSES_ROOT, '%s' % protocolname, 0 if write else reg.KEY_READ)
elif write:
pass
return reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\\Classes\\%s' % protocolname, 0, reg.KEY_READ)
except reg.error:
return None
def basekey(system = False):
if system:
return reg.OpenKey(reg.HKEY_CLASSES_ROOT, '')
else:
return reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\\Classes')
def keyToObj(.0):
(obj, objtype) = .0
if objtype in reg.REG_NONE:
return None
elif objtype in (reg.REG_SZ, reg.REG_EXPAND_SZ, reg.REG_RESOURCE_LIST, reg.REG_LINK, reg.REG_BINARY, reg.REG_DWORD, reg.REG_DWORD_LITTLE_ENDIAN, reg.REG_DWORD_BIG_ENDIAN, reg.REG_MULTI_SZ):
return obj
raise NotImplementedError, 'Registry type 0x%08X not supported' % (objtype,)
def register_microsoft(urlprotocol, system = True):
protocol = attrget(urlprotocol, 'protocol')
key = urlkey(protocol, system)
if not key:
reg.CreateKey(basekey(system), 'Software\\Classes\\%s' % protocol)
def isRegistered_microsoft(urlprotocol, system = True):
name = attrget(urlprotocol, 'protocol')
key = urlkey(name, system)
if not key:
return False
def _init_darwin():
pass
def _init_linux():
pass
try:
platform_call('_init')
except Exception:
print_exc()
if __name__ == '__main__':
print get('mailto')